package com.zhentao.controller;

import com.github.pagehelper.PageInfo;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.pay.dto.PayDto;
import com.zhentao.model.pay.pojo.AdMembershipCard;
import com.zhentao.service.AdMembershipCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/v1/admin/pay")
@Api(tags = "CardController-vip卡管理")
public class CardController {
    @Resource
    AdMembershipCardService adMembershipCardService;

    /**
     * 会员卡列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("会员卡列表")
    public ResponseResult list(@RequestBody PayDto dto){
        PageInfo<AdMembershipCard> list = adMembershipCardService.getList(dto);
        return ResponseResult.okResult(list);
    }

    /**
     * 会员卡类型列表
     * @return
     */
    @PostMapping("/typeList")
    @ApiOperation("会员卡类型列表")
    public ResponseResult typeList(){
        return adMembershipCardService.getTypeList();
    }

    /**
     * 会员卡列表添加
     * @param adMembershipCard
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("会员卡列表添加")
    public ResponseResult add(@RequestBody AdMembershipCard adMembershipCard){
        return adMembershipCardService.add(adMembershipCard);
    }

    /**
     * 会员卡列表更新
     * @param adMembershipCard
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("会员卡列表更新")
    public ResponseResult update(@RequestBody AdMembershipCard adMembershipCard){
        return adMembershipCardService.updateCard(adMembershipCard);
    }

    /**
     * 会员卡列表下架
     * @param id
     * @return
     */
    @PostMapping("/del")
    @ApiOperation("会员卡列表下架")
    public ResponseResult del(@RequestParam("id") Integer id){
        adMembershipCardService.removeById(id);
        return ResponseResult.okResult("下架成功");
    }
}
